package net.pessu.android.shoppoid.gui;

import java.util.ArrayList;
import java.util.HashMap;

import net.pessu.android.shoppoid.R;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.SimpleCursorAdapter;

public class ListArticlesBill extends ListView {
	
	Context currentContext;
	
	private static final String PRIXREDUIT = "prixreduit";

	private static final String TITRE = "titre";

	public ListArticlesBill(Context context) {
		super(context);
		setPressed(false);
	}

	public ListArticlesBill(Context context, AttributeSet attrs) {
		super(context, attrs);
		setPressed(false);
	}

	public ListArticlesBill(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		setPressed(false);
	}
	
	public void init(Context context){
		this.currentContext = context;
		setPressed(false);
	}

	public void setList(ArrayList<HashMap<String, String>> listArticle) {
		SimpleAdapter mSchedule = new SimpleAdapter(this.currentContext, listArticle,
				R.layout.itemdebrief, new String[] { "titre",
						"prixdebrief"}, new int[] { R.id.titre,
						R.id.prixdebrief });
		
		setAdapter(mSchedule);
		
	}

	public void setCursor(Cursor listArticlesAchetesC) {
        ListAdapter adapter = new SimpleCursorAdapter(
        		this.currentContext, // Context.
        		R.layout.itemdebrief,  
        		listArticlesAchetesC,                                              // Pass in the cursor to bind to.
                new String[] {TITRE, PRIXREDUIT},           // Array of cursor columns to bind to.
                new int[] {R.id.titre, R.id.prixdebrief});
		
		setAdapter(adapter);
		
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see android.widget.TextView#onFocusChanged(boolean, int,
	 * android.graphics.Rect)
	 */
	@Override
	protected void onFocusChanged(boolean focused, int direction,
			Rect previouslyFocusedRect) {
		// TODO Auto-generated method stub
		super.onFocusChanged(focused, direction, previouslyFocusedRect);
	}



	/*
	 * (non-Javadoc)
	 * 
	 * @see android.widget.TextView#onTouchEvent(android.view.MotionEvent)
	 */
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		return false;
	}


}
